package org.ph.share.lock.test.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * Thread 测试类
 * TimeUnit.SECONDS.sleep的使用
 *
 * @author Hush.
 * @since 2023/5/15 9:53
 */
@Slf4j
public class ThreadTest2 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread("t1") {
            @Override
            public void run() {

                log.info("test interrupt 1");
                try {
                    TimeUnit.SECONDS.sleep(5);

                } catch (InterruptedException e) {
                    log.error("test interrupt catch ", e);
                    throw new RuntimeException(e);
                } finally {
                    log.info("test  finally ");
                }
                log.info("test  run");

            }
        };
        TimeUnit.SECONDS.sleep(1);

        thread.start();
    }
}
